home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 018a / amac41.zip / RFR008.QM < prev    next >
Text File  |  1991-08-26  |  22KB  |  558 lines

  1. *                               RFR008.QM
  2. *                        Written By Tom Hogshead
  3. *                       [ See RFRMxx.QM For Use ]
  4. *                                8/21/91
  5. *  Key       Subfile                       Description                 Bytes
  6. * =====  ==============  ============================================ =======
  7. * @(1)                 --Swap Character at Cursor with NEXT Character    15
  8. * @(x)                 --   Alternate version of @1 by John Goodman      14
  9. * @(7)                 --   Alternate version of @1 by G. de Bruin       12
  10. * @(b)                 --   Slow version of @1 by Mike Konieczny         12
  11. * @(2)                 --Swap Two Characters LEFT of Cursor              16
  12. * @(y)                 --   Alternate version of @2 by John Goodman      16
  13. * @(3)                 --Swap Current Cursor Line with Line BELOW        12
  14. * @(9)                 --   Alternate version of @3, Use this instead     8
  15. * @(4)                 --Swap Current Cursor Line with Line ABOVE        14
  16. * @(0)                 --   Alternate version of @4, Use this instead     8
  17. * @(5)                 --Swap Word at Cursor with Word RIGHT of Cursor   20
  18. * @(e)                 --   Alternate version of @5                      18
  19. * @(6)                 --Swap Word at Cursor with Word LEFT of Cursor    21
  20. * @(8)                 --Duplicate Remainder of Previous Line            14
  21. *                           John Goodman, Author
  22.  
  23. *         {e:\up\RFRM*}--Return To RFRMxx.QM
  24. *
  25. *  (Timing) of Macros @1, @7 and @b
  26. *
  27. *-- eoi
  28.  
  29. * 
  30. * -----------------------------------------------------------
  31. * @(1) Swap Character at Cursor Position with Next Character
  32. *      John Goodman, Author
  33. * -----------------------------------------------------------
  34. * This macro will swap the character at the current cursor position
  35. * with the character to the right of the current character.  The cursor
  36. * will be placed to the right of the two swapped characters at the end
  37. * of the macro.  This macro is useful for correcting transposition
  38. * errors in existing text.  It maintains marked blocks and is
  39. * irrespective of all Toggle states.  Timing results comparing @1, @7
  40. * and @b are shown below in Timing.
  41.  
  42. *1325467  test
  43.  
  44. @1      MacroBegin
  45.         DupLine        * Duplicate the current line
  46.         CursorUp       * Move back to original line
  47.         DelCh          * Delete the 1st char of the pair
  48.         CursorDown     * Move back to dup-ed line
  49.         SplitLine      * Split the line at the same position
  50.         GetPrev        * Copy the 2nd char of the pair
  51.         CursorUp       * Return to original line
  52.         DelLine        * Delete the line
  53.         JoinLine       * Re-join the dup-ed line
  54.         CursorRight    * Get rid of extraneous char
  55.         DelCh
  56. *
  57. * 16 bytes Wed  08-07-1991  18:58:30 (JG @1, v 1)
  58. * 15 bytes Thu  08-08-1991  19:21:58 (JG @1, v 2 based on TH's @3/jg-0807b.qm)
  59.  
  60. * 
  61. * -----------------------------------------------------------
  62. * @(x) Swap Character at Cursor Position with Next Character
  63. *      Alternate version of @1 by John Goodman, one byte smaller
  64. * -----------------------------------------------------------
  65. * This macro will swap the character at the current cursor position
  66. * with the character to the right of the current character.  The
  67. * cursor will be placed to the right of the two swapped characters
  68. * at the end of the macro.  This macro is useful for correcting
  69. * transposition errors in existing text.  The macro will not work
  70. * correctly if used at or after the end of a line or on a line with
  71. * only one character.
  72. *
  73. @x  MacroBegin
  74.     DupLine        * Duplicate the current line
  75.     SplitLine      * Split the dup-ed line
  76.     DelLine        * Delete the beginning of the line
  77.     CursorUp       * Move up to original line
  78.     DelCh          * Delete 1st char in pair
  79.     CursorRight    * Move over 2nd char in pair
  80.     DelToEOL       * Delete remainder of line
  81.     JoinLine       * Re-join the line
  82.     CursorRight    * Move over the char
  83.     DelCh          * Delete unneeded char
  84. *
  85. * 14 bytes Fri  08-09-1991  17:44:24 (JG @x, changed from @1 by JG)
  86.  
  87. * 
  88. * -------------------------------------------------------
  89. * @(2) Swap the Two Characters to the Left of the Cursor
  90. *      Tom Hogshead and John Goodman, Authors
  91. * -------------------------------------------------------
  92. * Another macro that swaps the two characters to the left of the
  93. * cursor (which may be more useful if you've *just typed* a
  94. * transposition error)...
  95.  
  96. * This macro will swap the two characters to the left of the
  97. * cursor.  This macro is useful for correcting a transposition
  98. * error that has just been typed.
  99.  
  100. *1325467  test
  101.  
  102. @2      MacroBegin
  103.         DupLine         * Duplicate the current line
  104.         CursorLeft      * Move left one space
  105.         DelCh           * Delete the cursor character
  106.         CursorLeft      * Move to left most character to swap
  107.         SplitLine       * Split at cursor position
  108.         DelLine         * Delete dup'd line
  109.         CursorUp        * Move back to original line
  110.         DelCh           * Delete left most character to swap
  111.         CursorRight     * Move to starting cursor position
  112.         DelToEol        * Delete everything from starting pos right
  113.         JoinLine        * Join remainder of dup'd line
  114.         CursorRight     * Position cursor on first char after swapped chars
  115. *
  116. * 17 bytes Wed  08-07-1991  21:14:06 (JG/TH @2)
  117. * 16 bytes Thu  08-08-1991  22:27:55 (TH @4, in jg-0808b.qm/rfr008.qm)
  118.  
  119. * 
  120. * -------------------------------------------------------
  121. * @(y) Swap the Two Characters to the Left of the Cursor
  122. *      Alternate version of @2 by John Goodman
  123. * -------------------------------------------------------
  124.  
  125. * This macro will swap the two characters to the left of the cursor.
  126. * This macro is useful for correcting a transposition error that has
  127. * just been typed.  The macro will not work correctly when used more
  128. * than one character beyond the end of a line or on a line with only
  129. * zero or one characters in it.
  130.  
  131. * This macro is an alternate version of @2 and is the same size, but it
  132. * behaves better when invoked in column 1 or 2 of an *existing* line
  133. * (not a zero or 1 character line).
  134.  
  135. @y  MacroBegin
  136.     CursorLeft     * Move to beginning of pair
  137.     CursorLeft
  138.     DupLine        * Duplicate the current line
  139.     SplitLine      * Split the dup-ed line
  140.     DelLine        * Delete the beginning of the line
  141.     CursorUp       * Move up to original line
  142.     DelCh          * Delete 1st char in pair
  143.     CursorRight    * Move over 2nd char in pair
  144.     DelToEOL       * Delete remainder of line
  145.     JoinLine       * Re-join the line
  146.     CursorRight    * Move over the char
  147.     DelCh          * Delete unneeded char
  148. *
  149. * 16 bytes Fri  08-09-1991  18:39:28 (JG @y, changed from @2 by JG)
  150.  
  151. * 
  152. * ----------------------------------------------
  153. * @(3) Swap Current Cursor Line with Line Below
  154. * ----------------------------------------------
  155. * This macro swaps the current cursor line with the line below.  The
  156. * same thing could be accomplished using markline/moveblock but this
  157. * macro is written to maintain any marked block (excluding any marked
  158. * swapping lines) during execution and is irrespective of all Toggle
  159. * states.  The cursor is positioned at the beginning of the swapped
  160. * line after macro execution.  Line length is limited to 256 characters
  161. * using joinline.
  162.  
  163. * With the cursor on line_1:
  164. *            >  line_1
  165. *                       line_2
  166. * becomes
  167. * >                     line_2
  168. *               line_1
  169.  
  170. @3      MacroBegin
  171.         EndLine
  172.         JoinLine
  173.         DupLine
  174.         DelToEol
  175.         CursorUp
  176.         SplitLine
  177.         DelLine
  178.         BegLine
  179. *
  180. * 12 bytes Tue  08-13-1991  12:15:13 (TH @3)
  181.  
  182. * 
  183. * ----------------------------------------------
  184. * @(9) Swap Current Cursor Line with Line Below
  185. *      Alternate version of @3
  186. * ----------------------------------------------
  187.  
  188. * This macro swaps the current cursor line with the line below.  The
  189. * technique below using delline unkill is the simplest and best way to
  190. * do this.  This macro is written to maintain any marked block
  191. * (excluding any marked swapping lines) during execution and is
  192. * irrespective of all Toggle states.  The cursor is positioned at the
  193. * beginning of the swapped line after macro execution.
  194.  
  195. * With the cursor on line_1:
  196. *            >  line_1
  197. *                       line_2
  198. * becomes
  199. * >                     line_2
  200. *               line_1
  201.  
  202. @9      MacroBegin
  203.         CursorDown
  204.         DelLine
  205.         CursorUp
  206.         UnKill
  207. *
  208. * 8 bytes Thu  08-15-1991  16:23:00 (TH @9)
  209.  
  210. * 
  211. * ----------------------------------------------
  212. * @(4) Swap Current Cursor Line with Line Above
  213. * ----------------------------------------------
  214. * This macro swaps the current cursor line with the line above.  The
  215. * same thing could be accomplished using markline/moveblock but this
  216. * macro is written to maintain any marked block (excluding any marked
  217. * swapping lines) during execution and is irrespective of all Toggle
  218. * states.  The cursor is positioned at the beginning of the swapped
  219. * line after macro execution.  Line length is limited to 256 characters
  220. * using joinline.
  221.  
  222. * With the cursor on line_1:
  223. *               line_0
  224. *            >          line_1
  225. * becomes
  226. *                       line_1
  227. * >             line_0
  228.  
  229. @4      MacroBegin
  230.         CursorUp
  231.         EndLine
  232.         JoinLine
  233.         DupLine
  234.         DelToEol
  235.         CursorUp
  236.         SplitLine
  237.         DelLine
  238.         CursorDown
  239.         BegLine
  240. *
  241. * 14 bytes Tue  08-13-1991  12:15:23 (TH @4)
  242.  
  243. * 
  244. * ----------------------------------------------
  245. * @(0) Swap Current Cursor Line with Line Above
  246. *      Alternate version of @4
  247. * ----------------------------------------------
  248.  
  249. * This macro swaps the current cursor line with the line above.  The
  250. * technique below using delline unkill is the simplest and best way to
  251. * do this.  This macro is written to maintain any marked block
  252. * (excluding any marked swapping lines) during execution and is
  253. * irrespective of all Toggle states.  The cursor is positioned at the
  254. * beginning of the swapped line after macro execution.
  255.  
  256. * With the cursor on line_1:
  257. *               line_0
  258. *            >          line_1
  259. * becomes
  260. *                       line_1
  261. * >             line_0
  262.  
  263. @0      MacroBegin
  264.         CursorUp
  265.         DelLine
  266.         CursorDown
  267.         UnKill
  268. *
  269. * 8 bytes Thu  08-15-1991  16:23:00 (TH @0)
  270.  
  271. * 
  272. * ---------------------------------------------------
  273. * @(5) Swap Word at Cursor with Word Right of Cursor
  274. * ---------------------------------------------------
  275. * This macro swaps the cursor word with the first word right of cursor.
  276. * After execution, the cursor is positioned on the first word right of
  277. * the swapped words.  The last word in a line cannot be swapped with
  278. * the first word of the next line.  The same swapping could be
  279. * accomplished using markword/moveblock, but this macro is written to
  280. * maintain any marked block during execution irrespective of all Toggle
  281. * states.  Juxtaposition of text surrounding the swapping words is
  282. * maintained.
  283.  
  284. * With the cursor positioned on word_2:
  285. *                           v
  286. *                   word_1 word_2 word_3 word_4
  287. * becomes
  288. *                   word_1 word_3 word_2 word_4
  289. *                                        ^
  290.  
  291. @5      MacroBegin
  292.         AltWordSet
  293.         DupLine
  294.         WordRight
  295.         DelRtWord
  296.         WordLeft
  297.         SplitLine
  298.         DelLine
  299.         CursorUp
  300.         DelRtWord
  301.         WordRight
  302.         DelToEol
  303.         EndLine
  304.         CursorRight
  305.         JoinLine
  306.         WordRight
  307.         DefaultWordSet
  308. *
  309. * 20 bytes Tue  08-13-1991  15:13:08 (TH @5)
  310.  
  311. * 
  312. * ---------------------------------------------------
  313. * @(e) Swap Word at Cursor with Word Right of Cursor
  314. *      Alternate version of @5
  315. * ---------------------------------------------------
  316. * This macro swaps the cursor word with the first word right of cursor.
  317. * After execution, the cursor is positioned on the first word right of
  318. * the swapped words.  Juxtaposition of text surrounding the swapping
  319. * words is maintained.  It is an alternate version of @5 included only
  320. * to show a different technique using unkill.
  321.  
  322. * With the cursor positioned on word_2:
  323. *                           v
  324. *                   word_1 word_2 word_3 word_4
  325. * becomes
  326. *                   word_1 word_3 word_2 word_4
  327. *                                        ^
  328.  
  329. @e      MacroBegin
  330.         AltWordSet
  331.         MarkWord
  332.         DeleteBlock
  333.         DelCh
  334.         WordRight
  335.         SplitLine
  336.         CursorDown
  337.         UnKill
  338.         CursorUp
  339.         JoinLine
  340.         EndLine
  341.         CursorRight
  342.         JoinLine
  343.         DefaultWordSet
  344. * 20 bytes Tue 08-13-1991 15:13:08 (TH @5)
  345. * 18 bytes Tue  08-20-1991  16:22:56 (TH @e)
  346.  
  347. * 
  348. * --------------------------------------------------
  349. * @(6) Swap Word at Cursor with Word Left of Cursor
  350. * --------------------------------------------------
  351. * This macro swaps the cursor word with the first word left of cursor.
  352. * After execution, the cursor is positioned on the first word right of
  353. * the swapped words.  The first word in a line cannot be swapped with
  354. * the last word of the previous line.  The same swapping could be
  355. * accomplished using markword/moveblock, but this macro is written to
  356. * maintain any marked block during execution irrespective of all Toggle
  357. * states.  Juxtaposition of text surrounding the swapping words is
  358. * maintained.
  359.  
  360. * With the cursor positioned on word_2:
  361. *                           v
  362. *                   word_1 word_2 word_3 word_4
  363. * becomes
  364. *                   word_2 word_1 word_3 word_4
  365. *                                 ^
  366.  
  367. @6      MacroBegin
  368.         AltWordSet
  369.         WordRight
  370.         WordLeft
  371.         DupLine
  372.         DelRtWord
  373.         WordLeft
  374.         SplitLine
  375.         DelLine
  376.         CursorUp
  377.         DelRtWord
  378.         WordRight
  379.         DelToEol
  380.         EndLine
  381.         CursorRight
  382.         JoinLine
  383.         WordRight
  384.         DefaultWordSet
  385. *
  386. * 21 bytes Tue  08-13-1991  14:09:50 (TH @6)
  387.  
  388. * 
  389. * ---------------------------------------------------------------------
  390. * @(7) Swap Character at Cursor Position with Next Character
  391. *      Written by George de Bruin with Modifications by Tom Hogshead
  392. * ---------------------------------------------------------------------
  393. * This macro will swap the character at the current cursor position
  394. * with the character to the right of the current character.  The cursor
  395. * will be placed to the right of the two swapped characters at the end
  396. * of the macro.  This macro is useful for correcting transposition
  397. * errors in existing text.  This macro clears any marked blocks and is
  398. * an alternate version of @1 in Semware Macros Conference, message #544
  399. * and above.  Timing results comparing @1, @7 and @b are shown below in
  400. * Timing.
  401.  
  402. @7      MacroBegin
  403.         UnmarkBlock                     * Clear any marked block        |
  404.         MarkColumn MarkColumn           * Mark char at cursor pos
  405.         CursorRight CursorRight         * Move two spaces right
  406.         MoveBlock                       * Move marked char here
  407.         CursorRight                     * Move one more space right     |
  408.         UnmarkBlock                     * Clear marked char
  409. *
  410. * 12 bytes Mon  08-12-1991  20:24:58 (TH @7, mod to GdB @1 |)
  411.  
  412. * 
  413. * -----------------------------------------------------------------
  414. * @(b) Swap Character at Cursor Position with Next Character
  415. *      Written by Mike Konieczny with Modification by Tom Hogshead
  416. * -----------------------------------------------------------------
  417. * This macro will swap the character at the current cursor position
  418. * with the character to the right of the current character.  It is an
  419. * alternate version of @1, and written by Mike Konieczny in SemWare
  420. * RelayNet Conf, message #3410, 8/11/91.  I added  2 unmarkblocks and
  421. * one cursorright in order to compare timing results of @1 and @7.
  422. * Timing results comparing @1, @7 and @b are shown below in Timing.
  423. * This macro clears any marked block and is irrespective of all Toggle
  424. * states.
  425.  
  426. @b      macrobegin
  427.         unmarkblock             *| added TH
  428.         markcharacter
  429.         cursorright
  430.         cut
  431.         cursorright
  432.         paste
  433.         cursorright             *|
  434.         unmarkblock             *|
  435. *                                           
  436. *  9 bytes Tue  08-13-1991  19:45:29 (MK)
  437. * 12 bytes Tue  08-13-1991  19:47:32 (TH @b, mod to MK, added unmarkblock |)
  438.  
  439. * Check cursor position...
  440. *   v
  441. * 2134 @1
  442. *   v
  443. * 2134 @7
  444. *   v
  445. * 2134 @b
  446.  
  447. * (Timing) Macros @1, @7 and @b
  448. * ------------------------------
  449.  
  450. * Timing of these three macros was measured using the @1 timing macro
  451. * in TIMERxx.QM  tim001.qm by inserting each macro's commands in the @1
  452. * timing macro followed by 'begline delch' in order to have each macro
  453. * run consistently.  The macros were timed for 5,000 repeats and
  454. * results divided by 5 to give time for 1,000 repeats.  Results are
  455. * believed to be accurate and repeatable to +/- 1.0 second.
  456.  
  457. *                                      Seconds per
  458. *     Macro    Author       Bytes     1,000 Repeats
  459. *    =======  =======      =======   ===============
  460. *       @7       GdB         12            18     (fastest)
  461. *       @1       TH/JG       15            22     (maintain blocks)
  462. *       @b       MK          12            24     (slowest)
  463.  
  464. * The command sequence inserted in @1 timing macro, as an example, is:
  465.  
  466. *         DupLine
  467. *         CursorUp
  468. *         DelCh
  469. *         CursorDown
  470. *         SplitLine
  471. *         GetPrev
  472. *         CursorUp
  473. *         DelLine
  474. *         JoinLine
  475. *         CursorRight
  476. *         DelCh
  477. *         BEGLINE
  478. *         DELCH
  479.  
  480. * Additional tests were run on @7 and @b by selectively removing
  481. * commands to obtain that particular command's portion of the running
  482. * time.  Commands removed were 'moveblock' in @7 and 'paste', then
  483. * 'cut' in @b.  The other commands portion of running time were
  484. * estimated from the Relative Speed estimates in TIMER.SUM, along with
  485. * selected macro variations to get the best estimate possible.  These
  486. * results are as follows:
  487.  
  488. *                           -- Seconds per 1,000 Repeats --
  489. *                             @7          @1          @b
  490. *                            GdB        TH/JG         MK
  491. *                           -----       ------      ------
  492. *     paste                                           13 (54%)
  493. *     moveblock               9 (50%)
  494. *     delch         x 2                   4 (18%)
  495. *     delline                             3
  496. *     markcolumn    x 2       2
  497. *     cut                                             2  (17%)
  498. *     markcharacter                                   2
  499. *     unmarkblock   x 2       2                       2
  500. *     cursorright   x 3       2                       2
  501. *     dupline                             2
  502. *     splitline                           2
  503. *     getprev                             2
  504. *     cursorup      x 2                   2
  505. *     joinline                            2
  506. *     cursordown                          1
  507. *     cursorright                         1
  508. *     timing macro overhead   3           3           3
  509. *                           ----        ----        ----
  510. *     Total                  18          22          24
  511.  
  512. * @1 is slower than @7 because of the additional size and the extra
  513. * steps using the splitline/joinline technique.  If speed and size are
  514. * more important than maintaining marked blocks, @7 is the macro to
  515. * use.  If maintaining block marking is more important, @1 is the macro
  516. * to use.  I generally prefer, however, to write macros that maintain
  517. * marked blocks whenever possible as you can see from the effort John
  518. * Goodman and I put into optimizing @1 above and many other of our AMAC
  519. * macros.
  520.  
  521. * It is interesting to note that the moveblock's time is about 2/3 as
  522. * fast as cut/paste (9 vs 15 secs).  This must be in part do to the two
  523. * screen writes required for cut/paste vs one for moveblock.  It is
  524. * also interesting to note that paste is about 50% slower than
  525. * moveblock (13 vs 9 secs).  The reason for this with the inserted
  526. * commands necessary to test these swap macros is that in timing macro
  527. * @1, paste inserts the swapped character in the timing counter line,
  528. * thereby moving those characters to the right of the inserted
  529. * character that are not yet deleted one space right, and moveblock
  530. * does not.  These results suggest moveblock be used whenever possible,
  531. * rather than cut/paste.
  532.  
  533.  
  534. * 
  535. * ------------------------------------------
  536. * @(8) Duplicate Remainder of Previous Line
  537. *      John Goodman, Author
  538. * ------------------------------------------
  539. * This macro will copy the contents of the line above the current
  540. * line from the cursor position forward.  The macro works much like
  541. * entering the GetPrev command repeatedly, except that any
  542. * characters on the current line from the cursor position to the
  543. * end are deleted before the previous line is copied.
  544. *
  545. @8  MacroBegin
  546.     DelToEOL       * Delete remainder of current line
  547.     CursorUp       * Move to line above
  548.     DupLine        * Duplicate the line
  549.     SplitLine      * Split the line at the current cursor pos
  550.     DelLine        * Delete the beginning portion of the line
  551.     DelLine        * Delete the ending portion of the line
  552.     CursorDown     * Move below original line
  553.     UnKill         * Undelete the ending portion of the line
  554.     CursorUp       * Move back to original line
  555.     JoinLine       * Join the ending portion of previous line
  556. *
  557. * 14 bytes Tue  08-20-1991  17:15:58 (JG @8, changed from @3 by JG)
  558.